package util;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ResourceBundle;
import java.util.Vector;

import javax.swing.ButtonGroup;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

import modelUtil.Util;
import paginas.PaginaEntornoCreacionTeclados;
import AccionBoton.AccionBorradoCeldas;
import AccionBoton.AccionCerrar;
import AccionBoton.AccionFocoCreditos;

public class PopUpBorradoCeldas extends JDialog{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String _dimension;
	private PaginaEntornoCreacionTeclados _frame;
	private String _celdas;
	private String texto;
	private BotonPersonalizado b1,b2;
	private TransicionBotones policy;

	
	public PopUpBorradoCeldas(String dimension, String valor, PaginaEntornoCreacionTeclados frame){
		
		_dimension = dimension;
		_celdas = valor;
		_frame = frame;
		
		initComponents();
		 Vector<Component> order = new Vector<Component>(7);
	        order.add(b1);
	        order.add(b2);
	        
	       this.addWindowFocusListener(new WindowAdapter() {
	    	    public void windowGainedFocus(WindowEvent e) {
	    		    b1.requestFocusInWindow(); 
	    	    }
	    	});
	      this.setFocusable(true);
	       policy = new TransicionBotones(order);
	       this.setFocusTraversalPolicy(policy);
		
		Toolkit tk = Toolkit.getDefaultToolkit();
		Dimension screensize = tk.getScreenSize();
		setBounds((screensize.width/2) - 175, (screensize.height/2) -50, 350, 100);
		setAlwaysOnTop(true);
		setVisible(true);
		
	}
	
	public void initComponents(){
		
		GridLayout grid = new GridLayout(2,1);
		setLayout(grid);
		
		JPanel panel1 = new JPanel();
		JPanel panel2 = new JPanel();

		panel1.setPreferredSize(new Dimension(350,50));
		panel2.setPreferredSize(new Dimension(350,50));
		grid.addLayoutComponent("panel1", panel1);
		this.add(panel1);
		grid.addLayoutComponent("panel2", panel2);
		this.add(panel2);
		
		FlowLayout lay1 = new FlowLayout();
		lay1.setAlignment(FlowLayout.LEFT);
		panel1.setLayout(lay1);
		FlowLayout lay2 = new FlowLayout();
		lay2.setAlignment(FlowLayout.CENTER);
		panel2.setLayout(lay2);

		
		
		JLabel et = new JLabel(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_menu_eliminar_celdas"));
			
		lay1.addLayoutComponent("et", et);
		panel1.add(et);
		
		
		b1 = Util.BotonImagen(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_admin_aceptar"), "");
		b1.addFocusListener(new AccionFocoCreditos(b1));
		b1.addActionListener(new AccionBorradoCeldas(_dimension, _celdas, _frame,this));
		b2 = Util.BotonImagen(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_popup_admin_cancelar"), "");
		b2.addFocusListener(new AccionFocoCreditos(b2));
		b1.setPreferredSize(new Dimension(150,30));
		b1.setBackground(Color.lightGray);
		b2.setPreferredSize(new Dimension(150,30));
		b2.setBackground(Color.LIGHT_GRAY);
		b2.addActionListener(new AccionCerrar(this));
		
	    b1.getLabelTexto().getAccessibleContext().setAccessibleName(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_menu_eliminar_celdas_aceptar"));
	    b1.setToolTipText(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_menu_eliminar_celdas_aceptar"));
	    b1.setMnemonic(KeyEvent.VK_A);
	    b1.getLabelTexto().setDisplayedMnemonic(KeyEvent.VK_A);
	    b1.setFocusable(true);
	    
	    
	    b2.getLabelTexto().getAccessibleContext().setAccessibleName(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_menu_eliminar_celdas_cancelar"));
	    b2.setToolTipText(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_accesible_menu_eliminar_celdas_cancelar"));
	    b2.setMnemonic(KeyEvent.VK_C);
	    b2.getLabelTexto().setDisplayedMnemonic(KeyEvent.VK_C);
		b2.setFocusable(true);
		
		lay2.addLayoutComponent("b1", b1);
		panel2.add(b1);
		
		lay2.addLayoutComponent("b2", b2);
		panel2.add(b2);
		


		
		
	}
	
	
}
